package com.socket;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class ECHOClient {
    public static void main(String[] args) {
        try {
            Socket client = new Socket("localhost",9991);
            Scanner scanner = new Scanner(client.getInputStream());
            PrintWriter out = new PrintWriter(client.getOutputStream());
            boolean flag=true;
            while (flag) {
                String value = ECHOKeyBoadInputUtil.getString("请输入要发送的数据").trim();
                out.println(value);
                if (scanner.hasNext()) {
                    System.out.println("客户端:" + scanner.next());
                }
                if (value.equalsIgnoreCase("exit")) {
                    flag = false;
                }

            }
            client.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
